import { IFeidaoAiBrowserComponent } from '@feidao/web/interfaces';
import nodejs from '@feidao/web/atom/browser/msg/nodejs';
import render from '@feidao/web/atom/browser/render/render';
import P01 from './P01';

export default async function a002(fd: IFeidaoAiBrowserComponent, ...args: any[]) {
	// 删除
	const target_node = args[0].target;
	const status = target_node.getAttribute('data-feidao-status');
	if (status === '未分配') {
		const id = target_node.getAttribute('data-feidao-id');
		const res = await nodejs(fd.data.spaceid, 'exam_date_del', { _id: id });
		if (res === 'success') {
			alert('删除成功');
			const exam_id = fd.data.exam_id;
			const data = await nodejs(fd.data.spaceid, 'exam_date_find', { exam_id });
			render(fd, data, P01, 'P01', 'inner');
		} else {
			alert('删除失败');
		}
	} else {
		alert('只能删除未分配的考试时间');
	}
}
